package com.cqc.zhbjcqc.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.cqc.zhbjcqc.R;
import com.cqc.zhbjcqc.application.ImageLoaderOptions;
import com.cqc.zhbjcqc.bean.FragPicsBean;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * Created by ${cqc} on 2016/9/30.
 */

public class FragPicsAdapter extends ListViewBaseAdapter<FragPicsBean.DataBean.NewsBean> {
    public FragPicsAdapter(Context context, List<FragPicsBean.DataBean.NewsBean> list) {
        super(context, list);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder holder;
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.item_frag_pics,viewGroup,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        ImageLoader.getInstance().displayImage(list.get(position).getListimage(),holder.iv, ImageLoaderOptions.list_options);
        holder.tv.setText(list.get(position).getTitle());
        return convertView;
    }

    public class ViewHolder {

        public  ImageView iv;
        public  TextView tv;

        public ViewHolder(View itemView) {
            super();
            iv = (ImageView) itemView.findViewById(R.id.iv_frag_pics);
            tv = (TextView) itemView.findViewById(R.id.tv_frag_pics);
        }
    }
}
